/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package nc.bs.mo.mo2010;

import javax.naming.NamingException;
import nc.bs.logging.Logger;
import nc.bs.mm.pub.pub1020.DisassembleDMO;
import nc.bs.mo.mo2010.Disassemble;
import nc.bs.pub.SystemException;
import nc.vo.mm.pub.pub1020.ProduceCoreVO;
import nc.vo.mm.pub.pub1030.PickmHeaderVO;
import nc.vo.mm.pub.pub1030.PickmItemVO;
import nc.vo.mm.pub.pub1030.PickmVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;

public class SelfDisassemble extends Disassemble {
	public SelfDisassemble(String pk_corp, String gcbm, String date)
			throws NamingException, SystemException {
		super(pk_corp, gcbm, date);
	}

	protected PickmVO disassemble(PickmHeaderVO header)
			throws BusinessException {
		PickmVO pickm = new PickmVO();
		pickm.setParentVO(header);
		pickm.setChildrenVO(new PickmItemVO[] { this
				.createSelfPickmItemVO(header) });
		return pickm;
	}

	private PickmItemVO createSelfPickmItemVO(PickmHeaderVO headVO) {
		PickmItemVO vo = new PickmItemVO();
		vo.setPk_corp(headVO.getPk_corp());
		vo.setGcbm(headVO.getGcbm());
		vo.setFxid(headVO.getWlbmid());
		vo.setFlrq(new UFDate(headVO.getLogDate()));
		vo.setPk_produce(headVO.getPk_produce());
		vo.setWlbmid(headVO.getWlbmid());
		vo.setJldwid(headVO.getJldwid());
		vo.setPch(headVO.getPch());
		vo.setXlh(headVO.getXlh());
		ProduceCoreVO produceVO = null;

		try {
			produceVO = (new DisassembleDMO()).getFjldwInfo(headVO.getWlbmid());
		} catch (Exception arg4) {
			Logger.error(arg4.getMessage(), arg4);
			return null;
		}

		vo.setClbm(produceVO.getInvcode());
		vo.setClmc(produceVO.getInvname());
		vo.setClgg(produceVO.getInvspec());
		vo.setClxh(produceVO.getInvtype());
		vo.setWlth(produceVO.getGraphid());
		vo.setJldwmc(produceVO.getMeasname());
		vo.setFjldwid(produceVO.getFjldwid());
		vo.setFjldwmc(produceVO.getFjldwmc());
		vo.setFixedflag(produceVO.getFixedflag());
		vo.setFjlhsl(produceVO.getMainmeasrate());
		vo.setMaterclass(new Integer(0));
		vo.setGylx(new Integer(0));
		vo.setXelwfw(new UFDouble(0));
		vo.setTdbz(new Integer(0));
		vo.setKzbz(new Integer(1));
		vo.setZxlx(new Integer(0));
		vo.setSfATPjc(new UFBoolean(false));
		vo.setSfdc(new UFBoolean(false));
		vo.setSfzl(new UFBoolean(true));
		vo.setBlfs(new Integer(3));
		vo.setBlly(new Integer(1));
		vo.setSfkfl(new UFBoolean(true));
		vo.setDwde(headVO.getJhwgsl());
		vo.setDeyl(headVO.getJhwgsl());
		vo.setJhcksl(headVO.getJhwgsl());
		if (headVO.getFjhwgsl() != null) {
			vo.setFdwde(headVO.getFjhwgsl());
			vo.setFdeyl(headVO.getFjhwgsl());
			vo.setFjhcksl(headVO.getFjhwgsl());
		}

		vo.setLjcksl(new UFDouble(0));
		vo.setLjyfsl(new UFDouble(0));
		vo.setStatus(2);
		vo.setZyx1(headVO.getZyx1());
		vo.setZyx2(headVO.getZyx2());
		vo.setZyx3(headVO.getZyx3());
		vo.setZyx4(headVO.getZyx4());
		vo.setZyx5(headVO.getZyx5());
		return vo;
	}
}